var url="";
var model;
var request;
var Yun;
var result=false;
var result1=false;
var result2=false;
var result3=false;
function LoadData(){
    result=false;
    result1=false;
    result2=false;
    result3=false;

    LoadCopData();
    LoadLineData();
    LoadLine2Data();
}

function LoadCopData(){
      request.post('http://'+url+'/app/RunningInfo!ajaxCopLine?projectId='+GetQueryString('projectId')).success(function(data){
          console.log(data);

option1= {
    legend: {
        data:data.chillerList
    },
    backgroundColor:'white',
    grid: {
                            x: 43,
                            y: 33,
                            x2:33,
                            y2:33,
                            width:'85%'
                        },
    calculable : false,
    xAxis : [
        {
            type : 'category',

            data : data.xAxisData
        }
    ],
    yAxis : [
    {type:'value'}
    ],
    series : [        
    {
            name:'1#主机',
            type:'line',
            smooth:true,
            itemStyle: {normal: {areaStyle: {type: 'default'}}},
            data:data.series[0]
        },{
            name:'2#主机',
            type:'line',
             smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
            data:data.series[1]
        },{
            name:'3#主机',
            type:'line',
             smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
            data:data.series[2]
        }
        ]
}; 
 
      LoadQu();
      result1=true;
      if(result1&&result2&result3)  result=true;
         }).error(function(data,status,headers,config){
      if((status>=200&&status<300)||status===304||status===1223||status===0){
      $("body").html("网络访问出错！");
      }
      });
}

function LoadLineData(){
      request.post('http://'+url+'/app/RunningInfo!ajaxTemperatureLine?projectId='+GetQueryString('projectId')+'&timeRangeType='+model.timeRangeType).success(function(data){
          console.log(data);

option2 = {
    legend: {
        data:['室内温度','室外温度','冷冻水进口温度','冷冻水出口温度','冷却水进口温度','冷却水出口温度']
    },
    backgroundColor:'white',
    grid: {
                            x: 43,
                            y: 83,
                            x2:33,
                            y2:33,
                            width:'85%'
                        },
    calculable : false,
    xAxis : [
        {
            type : 'category',

            data : data.xAxisData
        }
    ],
    yAxis : [
    {type:'value'}
    ],
    series : [        
    {
            name:'室内温度',
            type:'line',
            smooth:true,
            data:data.series[0]
        },{
            name:'室外温度',
            type:'line',
             smooth:true,
            data:data.series[1]
        },{
            name:'冷冻水进口温度',
            type:'line',
             smooth:true,
            data:data.series[2]
        },{
            name:'冷冻水出口温度',
            type:'line',
             smooth:true,
            data:data.series[3]
        },{
            name:'冷却水进口温度',
            type:'line',
             smooth:true,
            data:data.series[4]
        },{
            name:'冷却水出口温度',
            type:'line',
             smooth:true,
            data:data.series[5]
        },
        ]
}; 


    console.log(option2);
      Loadline();
      result2=true;
      if(result1&&result2&result3)  result=true;
         }).error(function(data,status,headers,config){
      if((status>=200&&status<300)||status===304||status===1223||status===0){
      $("body").html("网络访问出错！");
      }
      });
}

function LoadLine2Data(){
      request.post('http://'+url+'/app/RunningInfo!ajaxInputPowerLine?projectId='+GetQueryString('projectId')).success(function(data){
          console.log(data);

option3 = {
    backgroundColor:'white',
    grid: {
                            x: 43,
                            y: 23,
                            x2:33,
                            y2:33,
                            width:'85%'
                        },
    calculable : false,
    xAxis : [
        {
            type : 'category',

            data : data.xAxisData
        }
    ],
    yAxis : [
    {type:'value'}
    ],
    series : [        
    {
            name:'功率曲线',
            type:'line',
            smooth:true,
            data:data.series
        }
        ]
}; 
      Loadline2();
      result3=true;
      if(result1&&result2&result3)  result=true;
         }).error(function(data,status,headers,config){
      if((status>=200&&status<300)||status===304||status===1223||status===0){
      $("body").html("网络访问出错！");
      }
      });
}

(function(){
	var app=angular.module('Yun',[]);
	app.controller('YunController',['$http','$window',function($http,$window){
     Yun=this;
     url ="120.26.110.125/jncloud";
		request=$http;
    bindEvent();
    model=Yun;
    Yun.showflag=false;
    Yun.timeRangeType=3;
    Yun.show={'display':'none'};
    Yun.showfont='最近两小时';
     // LoadCopData();
     // LoadLineData();
     // LoadLine2Data();
LoadData();
    Yun.Showpean=function(){
      if(!Yun.showflag)
      {
        Yun.showflag=true;
        Yun.show={'display':''};
      }
      else
      {
        Yun.showflag=false;
        Yun.show={'display':'none'};
      }
    }

   Yun.change3=function(){
     Yun.timeRangeType=3;

      Yun.showflag=false;
      Yun.show={'display':'none'};
      Yun.showfont='最近两小时';
      LoadLineData();
   }

      Yun.change0=function(){
     Yun.timeRangeType=0;

      Yun.showflag=false;
      Yun.show={'display':'none'};
      Yun.showfont='日温度';
      LoadLineData();
   }

      Yun.change1=function(){
     Yun.timeRangeType=1;

      Yun.showflag=false;
      Yun.show={'display':'none'};
      Yun.showfont='月温度';
      LoadLineData();
   }

      Yun.change2=function(){
     Yun.timeRangeType=2;

      Yun.showflag=false;
      Yun.show={'display':'none'};
      Yun.showfont='年温度';
      LoadLineData();
   }

	}]);
})();
